Imports ACFramework

Public Class TIntersector

#Region " Variables "
   Private m_lista As List(Of ACLista)
   Private m_lista2 As List(Of ACLista)
   Private m_listaTmp As List(Of ACLista)
   Private bs_lista As BindingSource
   Private bs_lista2 As BindingSource
   Private bs_listaFiltrada As BindingSource
   Private m_tipo As TipoLista

   Public Enum TipoLista
      Filtrador
      Ordenador
   End Enum

#End Region

#Region " Propiedades "

#End Region

#Region " Constructores "
   Public Sub New()

      ' This call is required by the Windows Form Designer.
      InitializeComponent()
      ' Add any initialization after the InitializeComponent() call.
      NsTextBoxNumerico1.Text = 100
      m_tipo = TipoLista.Filtrador
      Select Case m_tipo
         Case TipoLista.Filtrador
            TextBox1.Text = ACLista.Codigo & "=" & ACLista.Codigo
            AddHandler Button1.Click, AddressOf Filtrador_Click
            Label2.Text = "Filtrado Por:"
            Me.Text = "FILTRADOR"
            Button1.Text = "Filtrar Lista"
         Case TipoLista.Ordenador
            TextBox1.Text = "NSCodigo ASC, NSDescripcion ASC"
            AddHandler Button1.Click, AddressOf Ordenador_Click
            Label2.Text = "Ordenado Por:"
            Me.Text = "ORDENADOR"
            Button1.Text = "Ordenar Lista"
      End Select
   End Sub
#End Region

#Region " Metodos "

#End Region

#Region " Metodos de Controles"
   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      Try
         m_lista = New List(Of ACLista)
         m_lista2 = New List(Of ACLista)
         Dim i As Integer = CType(NsTextBoxNumerico1.Text, Integer)
         For index As Integer = 1 To i
            Dim i1 As Integer = (Int(Rnd() * i * 10))
            m_lista.Add(New ACLista(IIf(CheckBox1.Checked, i1.ToString(), index.ToString()), "Descripcion: " & i1.ToString()))
            Dim i2 As Integer = (Int(Rnd() * i * 10))
            m_lista2.Add(New ACLista(IIf(CheckBox1.Checked, i2.ToString(), index.ToString()), "Descripcion: " & i2.ToString()))
         Next
         bs_lista = New BindingSource()
         bs_lista.DataSource = m_lista
         C1FlexGrid1.DataSource = bs_lista
         BindingNavigator1.BindingSource = bs_lista
         C1FlexGrid1.Cols(0).Width = 20

         bs_lista2 = New BindingSource()
         bs_lista2.DataSource = m_lista2
         C1FlexGrid2.DataSource = bs_lista2
         BindingNavigator2.BindingSource = bs_lista2
         C1FlexGrid2.Cols(0).Width = 20
      Catch ex As Exception
         Throw ex
      End Try
   End Sub

   Private Sub Filtrador_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
      Try
         Dim filter As New ACInterseccion(Of ACLista, ACLista)
         filter.ACFiltro = TextBox1.Text

         bs_listaFiltrada = New BindingSource()
         bs_listaFiltrada.DataSource = filter.ACFiltrar(m_lista, m_lista2, ACInterseccion(Of Global.ACFramework.ACLista, Global.ACFramework.ACLista).TipoLike.Intersectados)
         C1FlexGrid3.DataSource = bs_listaFiltrada
         BindingNavigator3.BindingSource = bs_listaFiltrada
         C1FlexGrid3.Cols(0).Width = 20
      Catch ex As Exception
         Throw ex
      End Try
   End Sub

   Private Sub Ordenador_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
      Try
         Dim Order As New ACOrdenador(Of ACLista)
         Order.ACOrdenamiento = TextBox1.Text

         bs_listaFiltrada = New BindingSource()
         m_listaTmp = New List(Of ACLista)(m_lista)
         m_listaTmp.Sort(AddressOf Order.ACCompare)
         bs_listaFiltrada.DataSource = m_listaTmp
         C1FlexGrid2.DataSource = bs_listaFiltrada
         BindingNavigator2.BindingSource = bs_listaFiltrada
         C1FlexGrid2.Cols(0).Width = 20
      Catch ex As Exception
         Throw ex
      End Try
   End Sub


#End Region


End Class